// Fill out your copyright notice in the Description page of Project Settings.


#include "OssTaskTickMag.h"
#include "Misc/ScopeLock.h"

FOssTaskTickMag* FOssTaskTickMag::tickkMag = new FOssTaskTickMag();

FOssTaskTickMag::FOssTaskTickMag()
{

}
FOssTaskTickMag::~FOssTaskTickMag()
{


}

void FOssTaskTickMag::AddTask(IOssTaskTick* task)
{
	FScopeLock ScopeLock(&Mutex);
	taskList.AddUnique(task);
}
void FOssTaskTickMag::RemoveTask(IOssTaskTick* task)
{
	FScopeLock ScopeLock(&Mutex);
	taskList.Remove(task);
}

void FOssTaskTickMag::Tick(float DeltaTime)
{
	TArray<IOssTaskTick*> copyList = TArray<IOssTaskTick*>(taskList);
	for (IOssTaskTick* task : copyList)
	{
		task->TickTask(DeltaTime);
	}
}


TStatId FOssTaskTickMag::GetStatId() const
{
	RETURN_QUICK_DECLARE_CYCLE_STAT(FOssTaskTickMag, STATGROUP_Tickables);
}

FOssTaskTickMag* FOssTaskTickMag::GetTickMag()
{
	return tickkMag;
}

